function [] = main_1(img)
    % 对比原始图像 加了椒盐噪声图像 不同大小模板的滤波后的图像的区别
    function [output]=averagefilt2(img, sz)
        % 包装均值滤波方便回调
        output = imfilter(img, fspecial('average', sz));
    end

    function []=showTypeFiltRes(img, callback, typeStr, figureNum)
        % 包装滤波与展示函数降低代码复用
        imgList = {};
        titleList = {};
        imgWithNoise = imnoise(img, 'salt & pepper', 0.05);

        imgList{end + 1} = img;
        titleList{end + 1} = '原始图像';
        imgList{end + 1} = imgWithNoise;
        titleList{end + 1} = '加噪图像';

        for i = 3:2:9
            imgList{end + 1} = callback(imgWithNoise, [i, i]);
            titleList{end + 1} = sprintf('%dx%d模板%s滤波', i, i, typeStr);
        end

        figure(figureNum);
        for i = 1:6
            subplot(2, 3, i);
            imshow(imgList{i});
            title(titleList{i});
        end
    end

    showTypeFiltRes(img, @averagefilt2, '均值', 1);
    showTypeFiltRes(img, @medfilt2, '中值', 2);
    showTypeFiltRes(img, @wiener2, '自适应', 3);
end